package org.apache.lucene.ocean.database;

import java.io.Serializable;

import org.apache.lucene.ocean.Index.IndexSnapshot;
import org.apache.lucene.ocean.Index.MergedDocMap;
import org.apache.lucene.ocean.util.Timeout;

/**
 * Abstract cache key.  Subclasses implement the createObject method 
 * to create the cached value.
 * @param <V>
 */
public abstract class CacheKey<V> implements Serializable {
  /**
   * Create 
   * @param indexSnapshot IndexSnapshot for which the value should be created from
   * @param timeout Timeout if it is possible the creation of the value will take too long
   * @return The new cached value
   * @throws Exception
   */
	public abstract V createObject(IndexSnapshot indexSnapshot, Timeout timeout) throws Exception;
  
	/**
	 * Allows merging of like cache key values into a new value using the given 
	 * MergedDocMap
	 * @param mergedDocMap
	 * @return The merged value
	 * @throws Exception
	 */
	public V merge(MergedDocMap mergedDocMap) throws Exception {
	  throw new UnsupportedOperationException(""); 
	}
}
